/*
 * @Description: App接单模式设置  OrderModeSettings
 * @version: 
 * @Company: 
 * @Author: ZhengZhuang
 * @Date: 2019-08-26 14:25:29
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-12-11 16:11:32
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:C20Driver/provider/driver_information.dart';
import 'package:C20Driver/utils/utils.dart';
import 'package:provider/provider.dart';

class OrderModeSettings extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DriverInformation provider =
        Provider.of<DriverInformation>(context, listen: false);
    return Scaffold(
      appBar: AppBar(
        title: Text('模式设置'),
        elevation: 0,
      ),
      body: Container(
        padding: EdgeInsets.only(
            left: ScreenUtil().setWidth(20.0),
            right: ScreenUtil().setWidth(20.0),
            top: ScreenUtil().setWidth(20)),
        child: Column(
          children: <Widget>[
            Card(
              child: SwitchListTile(
                value: Provider.of<DriverInformation>(context)
                        .driverInfo
                        .workingStatus ==
                    '0020',
                onChanged: (val) {
                  if (provider.driverInfo.workingStatus == '0030') {
                    // provider.setDriverInformation(workingStatus: '0020');
                    Utils.setFaceRecognition(context);
                  } else {
                    // provider.setDriverInformation(workingStatus: '0030');
                    Utils.setWorkimgStatus(context);
                  }
                },
                title: Text('实时单'),
                selected: false,
                activeColor: Color(0xff3FB956),
              ),
            ),
            // _reservationOrderWidget(context, appOrderStatus),
          ],
        ),
      ),
    );
  }

  // 预约订单
  Widget _reservationOrderWidget(context, appOrderStatus) {
    return Card(
      child: Column(
        children: <Widget>[
          SwitchListTile(
            value: appOrderStatus.reservationOrder,
            onChanged: (val) {
              // Provide.value<AppOrderStatus>(context).setReservationOrder();
            },
            title: Text('预约单'),
            selected: false,
            activeColor: Color.fromARGB(255, 255, 153, 0),
          ),
          _timeAppointment(context, appOrderStatus),
        ],
      ),
    );
  }

  // 预约时间
  Widget _timeAppointment(context, appOrderStatus) {
    if (appOrderStatus.reservationOrder) {
      return Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              InkWell(
                child: Container(
                  alignment: Alignment.center,
                  width: ScreenUtil().setWidth(220.0),
                  height: ScreenUtil().setWidth(100.0),
                  decoration: BoxDecoration(
                    color: Color.fromARGB(255, 242, 242, 242),
                    borderRadius:
                        BorderRadius.circular(ScreenUtil().setWidth(6.0)),
                  ),
                  child: Text(appOrderStatus.appointmentStartTime),
                ),
                // onTap: () => Provide.value<AppOrderStatus>(context)
                //     .setAppointmentStartTime(context),
              ),
              Container(
                width: ScreenUtil().setWidth(130.0),
                height: ScreenUtil().setWidth(2.0),
                color: Color.fromARGB(255, 228, 228, 228),
              ),
              InkWell(
                child: Container(
                  alignment: Alignment.center,
                  width: ScreenUtil().setWidth(220.0),
                  height: ScreenUtil().setWidth(100.0),
                  decoration: BoxDecoration(
                    color: Color.fromARGB(255, 242, 242, 242),
                    borderRadius:
                        BorderRadius.circular(ScreenUtil().setWidth(6.0)),
                  ),
                  child: Text(appOrderStatus.appointmentEndTime),
                ),
                // onTap: () => Provide.value<AppOrderStatus>(context)
                // .setAppointmentEndTime(context),
              ),
            ],
          ),
          SizedBox(
            height: ScreenUtil().setWidth(30.0),
          ),
        ],
      );
    } else {
      return Container();
    }
  }
}
